import logging
import os

from google.appengine.dist import use_library
use_library('django', '1.2')

from google.appengine.ext import db
from google.appengine.ext import webapp
from google.appengine.ext.webapp import template
from google.appengine.ext.webapp.util import run_wsgi_app


class Student(db.Model):
  name = db.StringProperty(required=True)
  location = db.StringProperty(required=True)


class MapHandler(webapp.RequestHandler):
  def get(self):
    students = Student.all()
    locations = [student.location for student in students]
    names = [student.name for student in students]

    labels = []
    i = 0
    for name in names:
      label = 'f%s,000000,0,%d,10' % (name, i)
      labels.append(label)
      i += 1

    template_values = {
        'locations': '|'.join(locations),
        'labels': '|'.join(labels),
        'students': students
    }

    path = os.path.join(os.path.dirname(__file__), 'map.html')
    self.response.out.write(template.render(path, template_values))

  def post(self):
    name = self.request.get('name')
    location = self.request.get('location')
    student_to_delete = self.request.get('student')

    if name and location:
      student = Student(name=name, location=location)
      student.put()

    if student_to_delete:
      student = Student.get(student_to_delete)
      if student:
        student.delete()

    self.get()


application = webapp.WSGIApplication([('/', MapHandler)],
                                     debug=True)


def main():
    run_wsgi_app(application)

if __name__ == "__main__":
    main()



<!DOCTYPE html>
<html>
  <head>
    <title>Student Map</title>
  </head>
  <body>
    <h1>Student Map</h1>

    <h2>Enter your information</h2>
    <form action="/" method="post">
      Name: <input type="text" name="name">
      Location: <input type="text" name="location">
      <input type="submit" value="Click Me">
    </form>
    
    <h2>The Map</h2>
    <img src="https://chart.googleapis.com/chart?cht=map:fixed=-60,-180,80,180&chs=500x500&chco=CCCCCC|FF0000&chld={{ locations }}&chm={{ labels }}" alt="Map">

    <h2>Delete a Student</h2>
    <form action="/" method="post">
      {% for student in students %}
        <div>
          <input type="checkbox" name="student" value="{{ student.key }}">
          {{ student.name }}: {{ student.location }} 
        </div>
      {% endfor %}
      <input type="submit" value="Delete">
    </form>

  </body>
</html>
